package com.gt.quality.system.controller;


import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.gt.quality.base.BaseCommonController;
import com.gt.quality.base.BaseCommonService;
import com.gt.quality.base.pojo.BaseLimitRequest;
import com.gt.quality.system.entity.SysDictData;
import com.gt.quality.system.service.SysDictDataService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 字典数据表(SysDictData)表控制层
 *
 * @author makejava
 * @since 2026-12-26 11:20:03
 */
@RestController
@RequestMapping("sysDictData")
@Tag(name = "数据字典值项")
public class SysDictDataController extends BaseCommonController<SysDictData> {

    @Override
    protected void extendBeforeBySave(SysDictData obj) {
        obj.setDictCode(IdWorker.getId());
        super.extendBeforeBySave(obj);
    }

    @Override
    protected void extendBeforeByQueryLimit(BaseLimitRequest<SysDictData> limitRequest) {
        limitRequest.setExcludeCol(Map.of("dictType", "EQ"));
        super.extendBeforeByQueryLimit(limitRequest);
    }

    /**
     * Description:  根据字典类型查询字典数据
     *
     * @param dictType 字典类型
     * @author: makeJava
     * @date: 2026-12-26 11:20:03
     */
    @RequestMapping(value = "/{dictType}", method = {RequestMethod.GET})
    public List<SysDictData> getDictDataByDictType(@PathVariable("dictType") String dictType) {
        return sysDictDataService.getDictDataByDictType(dictType);
    }

    /**
     * 服务对象
     */
    private SysDictDataService sysDictDataService;

    @Autowired
    public void setSysDictDataService(SysDictDataService service) {
        this.sysDictDataService = service;
    }

    @Override
    public BaseCommonService<SysDictData> getThisService() {
        return sysDictDataService;
    }

    @Override
    protected boolean isSuperExcel() {
        return false;
    }
}
